import request from '@/utils/request'

// 添加知识
export function addKnowledge(params) {
    return request({
        method: 'post',
        url: '/discuss/addByKnowledge',
        data: params,

    })
}

// 分页查询所有知识
export function selectKnowledgesPage(params) {
    return request({
        method: 'get',
        url: 'knowledge',
        params: params,
    })
}

//根据id修改知识
export function updateKnowledgeById(params) {
    return request({
        method: 'put',
        url: 'knowledge/' + params.knowledgeId,
        data: params,

    })
}

// 根据id删除知识
export function deleteKnowledgeById(params) {
    return request({
        method: 'delete',
        url: 'knowledge/' + params.knowledgeId,
        params: params,

    })
}

// 根据id查询知识信息
export function selectKnowledgeById(params) {
    return request({
        method: 'get',
        url: 'knowledge/' + params.knowledgeId,

    })
}

// 根据登录用户查询知识 
export function selectKnowledgeByUsername(params) {
    return request({
        method: 'get',
        url: 'knowledge/selectByUsername/',

    })
}

// 根据登录用户查询知识 
export function selectComment(params) {
    return request({
        method: 'get',
        url: `/discuss/selectByKnowledge/${params.knowledgeId}`,

    })
}

// 增加评论
export function addComment(params) {
    const discussesDTO = params
    return request({
        method: 'post',
        url: `/discuss/addByKnowledge`,
        data: discussesDTO,
        // Headers: {
        //     'Content-Type': 'application/json'
        // }
    })
}